ReadMe.htmlTEXTttxtòs~©N©N ÅŶZMacHTTP Read Me

MacHTTP Read Me

Current version is 1.2.1, 1/4/93

1.0 Introduction

What is it?

MacHTTP is a server for Macs participating in the World Wide Web (WWW). It allows you to serve hypertext documents to other WWW users from your Macintosh. This version allows you to serve text documents (like HyperText Markup Language documents) as well as binary files (GIFs, f'rinstance). In addition, MacHTTP supports the execution of AppleScripts that can return HTML. This allows you to generate documents on the fly from data base queries, etc. This server works with the standard WWW clients as well as clients like Mosaic that support embedded graphics and it supports HTTP version "0.9".

The server places a very small load on your Mac, both in memory and CPU requirements. It should run fine in the background on any Mac with MacTCP installed and System 7.

MacHTTP is being written by Chuck Shotton, from the University of Texas Houston Health Science Center's Office of Academic Computing. Questions can be addressed to cshotton@oac.hsc.uth.tmc.edu. The latest version of MacHTTP can FTPed from oac.hsc.uth.tmc.edu in the public/mac/MacHTTP directory.

Current information about MacHTTP can be found on the MacHTTP home page at http://www.uth.tmc.edu/mac_info/machttp_info.html.

What's New?

Security has been beefed up by providing access controls on a host by host basis. The config file now supports the "ALLOW" and "DENY" keywords, which specify partial or complete IP addresses for hosts allowed or refused service by MacHTTP.

MacHTTP can now be configured to run on any free IP port using the PORT command in the configuration file. So you can now run multiple servers on one Mac if you make multiple copies of MacHTTP and run them. This would allow one server to provide secure access to some documents, for example, while another server provides anonymous access to others.

The maximum number of simultaneous users can now be configured via the MAXUSERS command in the config file. There is no longer a fixed upper limit. You will need to adjust the memory allocation for MacHTTP accordingly.

Timeouts for inactive HTTP connections have been implemented. The timeout value can be adjusted with the TIMEOUT command in the config file.

The log file format has been modified slightly. Information is now separated by tabs rather than spaces to facilitate importing log data into spreadsheets and databases.

MacHTTP now supports AppleEvents for remotely configuring MacHTTP while it is running.

Metrics on connections and memory usage are now displayed in the status window.

A couple of new options were added to hide the status window when MacHTTP is in the background and to allow the server to be gracefully shut down by refusing new incoming connections.

A "feature" was fixed that prevented MacHTTP and certain WWW clients consistently working together.

MacHTTP 1.2.1 addition: fixed start-up problem that caused MacHTTP to quit if the Component Manager wasn't installed.

The documentation has been completely rewritten.

2.0 Installing MacHTTP

System Requirements: MacHTTP requires System 7. If you want to take advantage of advanced features like searchable documents and clickable maps, you also need to have AppleScript installed. Obviously, MacHTTP also needs MacTCP to run.

MacHTTP has been tested on Mac II and Quadra family CPUs and works fine. Unfortunately, MacHTTP doesn't work and play well with 68000-based Macs like SEs and PowerBook 100s. Anyone who figures out why will be rewarded with an immediate upgrade!

Installing MacHTTP is extremely easy. Simply unarchive MacHTTP using a relatively recent version of something like Stuffit Expander or UnStuffit. The resulting folder already has everything installed in the proper places. You may place this folder on any disk, in any location.

Once you have MacHTTP unstuffed, simply double-click the application to activate the server. Use a WWW client like Mac Mosaic to connect to the following URL, substituting your Mac's host name or IP address in place of "your.host.name":

http://your.host.name/

3.0 Configuring MacHTTP

MacHTTP is configured by making changes to the "MacHTTP.config" file found inside the MacHTTP folder. This file consists of a series keywords and arguments that adjust various parameters affecting how MacHTTP runs. MacHTTP.config is a plain text file that can be modified using any text editor, including TeachText.

Configuration File

This section describes the commands that can be entered in the MacHTTP.config file to modify MacHTTP's behavior. Each section describes keywords, their arguments, and provides examples of their use. Open and read the comments in the MacHTTP.config file for more information.

Each command in the config file must start on a line by itself and each line should start with a keyword. Lines that don't start with a recognized keyword are considered as comments. Arguments specified inside angle brackets ("<", ">") should be replaced with the appropriate value for your server in the config file, omitting the angle brackets.

Special Files

There are several commands in the config file that define the names of special files used by MacHTTP.

INDEX <file name>: specifies the Home Page or Index for the server. This is the default document returned if a WWW client accesses your server and specifies the document "/" or no document at all.

If omitted, the default file name is ":Default.html" (no quotes).

ERROR <file name>: specifies the file returned by the server if an error occurs. This is usually an information message informing the user that a requested file cannot be found.

If omitted, the default file name is ":Error.html" (no quotes).

LOG <file name>: specifies the log file for the server. A log of all client accesses is maintained in this file. See the <Log File section below for more details.

If omitted, logging is disabled and no log file will be created.

NOACCESS <file name>: specifies the file to be returned by the server if a client that is not authorized to access the server attempts to request a file. See the Security section below for more details.

If omitted, the default file name is ":NoAccess.html" (no quotes).

Examples:

ERROR   :Error.html
INDEX   :Default.html
LOG     :MacHTTP.log
NOACCESS :NoAccess.html

Note that the file names begin with a ":". This tells MacHTTP to look within the same folder as the application for the files. While not required, it's a good idea to make sure the ":" is included for security reasons.

Suffix Mapping

MacHTTP needs to know the difference between text and binary files in order to use the appropriate file transfer method when returning data to a WWW client. For example, HTML (HyperText Markup Language) are text files and need to be converted before transmission to a WWW client because the Macintosh TEXT file format (CR at the ends of lines) is unsuitable for many WWW clients, which expect CR/LF at the ends of lines.

Also, some files like QuickTime movies and GIF images need to be transmitted to the client as byte for byte copies of the original file, using a "binary" transfer mode. In order to help MacHTTP distinguish which transfer method to use, you may specify up to 10 "suffix mappings" in the config file. These mappings tell MacHTTP whether to use a text or binary file transfer when sending a file, based on the suffix of the file's name.

Last of all, MacHTTP can execute AppleScripts and return the results of the script execution back to WWW clients. MacHTTP needs to be able to differentiate between files that are simply sent directly to the client (i.e., binary and text) and files that must be executed first (i.e., AppleScript).

There can be a maximum of 10 suffix mappings defined in the config file. If fewer than 10 mappings are provided, MacHTTP uses internal defaults to supply the missing mappings. When MacHTTP starts up, the status window displays the 10 suffix mappings plus the default file type for file names that don't match one of the 10 mappings.

TEXT <suffix>: Files ending with the specified suffix will have carraige returns translated to carraige return/line feed before transmission to the client.

BINARY <suffix>: Files ending with the specified suffix will be sent to the client without modification. Only the data fork of the file is transmitted.

SCRIPT <suffix>: Files ending with the specified suffix will be loaded and executed as an AppleScript source file. The script is expected to generate HTML text and return it to MacHTTP as the result of script execution. This result will then be transmitted to the client as TEXT files above.

DEFAULT <type>: "type" can be one of TEXT, BINARY, or SCRIPT. The DEFAULT command specifies the default file type to be used if a file's suffix doesn't match one of the 10 defined suffix mappings.

Examples:

TEXT    .HTML
BINARY  .GIF
SCRIPT  .SCRIPT
DEFAULT TEXT

Security

Security can be provided by MacHTTP on a host by host basis. You may specify hosts and networks to ALLOW or DENY access to. MacHTTP matches the IP address of a client requesting a file to a table of security directives. Based on the matches found, MacHTTP will either return the requested file to the client or issue a message (usually from the file specified by the NOACCESS command) saying access is denied.

ALLOW <IP address>: Specifies the partial or complete IP address of a host (or hosts) that is allowed to access the server.

DENY <IP address>: Specifies the partial or complete IP address of a host (or hosts) that is denied access to the server.

An unlimited number of security directives may appear in the config file. If none are present, then any client may access the server. If one or more directives is present in the config file, the directives are evaluated in the order they appear in the config file to determine whether a client is allowed to access the server.

If security directives are present in the config file, there is an implicit "DENY *" that is evaluated before any directives in the file. This means that all clients are denied and you must explicitly allow clients by using the ALLOW command to specify complete or partial addresses of clients which can access the server.

Examples:

ALLOW 129.106.
DENY  129.106.30
ALLOW 129.106.30.1.

These example statements are evaluated as follows. First, the implicit "DENY *" is evaluated, implying that no hosts may access the server. The first ALLOW statement specifies that all clients with addresses that begin with "129.106." will be allowed to connect to the server.

The DENY statement removes all clients with IP addresses that begin with "129.106.30" from the list of hosts that may access the server. Important note: The DENY statement not only matches all hosts in the "129.106.30" subnet, but also all hosts in "129.106.301", "129.106.302", etc. If you wanted to only restrict hosts in the "129.106.30" subnet, you should add a trailing "." to the IP address (i.e., "129.106.30.").

The final ALLOW statement explicitly enables the host "129.106.30.1". This statement matches only this specific host. MacHTTP always appends a trailing "." when comparing a client's IP address to the security entries. This means to match exactly one host with an ALLOW or DENY statement, the IP address argument must end with a "."

Port Number

MacHTTP defaults to listening for all incoming connections on the standard HTTP port 80. It is possible to change this number, allowing multiple MacHTTP servers to run on one Mac on different ports. An example might include running a public access server on port 80 and a restricted access server on port 1080. Note, port numbers below 1024 are reserved for well known services such as telnet, FTP, HTTP, Gopher, etc. If you change the port number for MacHTTP, you should use a number above 1024.

PORT <number>: Specifies the port number that MacHTTP will listen to for all incoming connections. The default is port 80 if this line is omitted from the config file

User Limit

MacHTTP will allow you to define a maximum number of users that may be simultaneously connected to the server. This is useful for servers with limited resources or for extremely busy servers that need to limit the number of queued requests.

The minimum number of simultaneous users is 3. Because of the way MacHTTP handles incoming requests and terminates connections, it is possible for a single, fast client to create a new connection before the previous one is dropped by MacHTTP. This, coupled with the fact that MacHTTP always reserves one connection for listening for incoming client requests means that at least 3 connections should be provided for at a minimum.

The maximum number of users is arbitrarily limited to 1000. Since MacHTTP can only transmit the data for one request to a client at a time, all other clients' requests are queued and executed in turn. Setting the maximum number too high will result in intolerable delays for clients. These delays could exceed MacHTTP's timeout value for inactive connections, so it's probably a good idea to leave the maximum users setting somewhere between 8 and 20.

Incoming clients that exceed the maximum number of users will be informed that the server is too busy to handle their request.

MAXUSERS <number>: Specify the maximum number of simultaneous users allowed to connect to MacHTTP. Values between 3 and 1000 are allowed. The default is 8 if this statement is omitted from the config file.

Timeout

MacHTTP will disconnect any client that fails to interact with the server after a specified amount of idle time has passed. If it takes longer than the timeout period for MacHTTP to complete a client's request (i.e., the server is busy, or an AppleScript takes a long time to execute), the client will be disconnected as well. Therefore, it is important to monitor the average time that clients wait in the queue and adjust this value accordingly.

TIMEOUT <seconds>: Specifies the maximum amount of idle time in seconds before MacHTTP disconnects a client's inactive connection. The minimum value is 15 seconds. The maximum value is 600 seconds and the default is 90 seconds if this statement is omitted from the config file.

Hiding in the Background

MacHTTP can optionally hide its status window when running in the background. This feature can be temporarily set from the Option menu or set permanently by using the HIDEWINDOW command in the config file.

HIDEWINDOW: If this command is present in the config file, MacHTTP's status window will be hidden when the application is running in the background.

MacHTTP Menus

Most configuration of MacHTTP occurs in the config file. However, certain options that affect the status window server behavior are implemented as menus. This section describes the functions contained in these menus.

All MacHTTP menu functions can be invoked via AppleEvents. So if MacHTTP is running on a "headless" Mac or you want to use AppleScript to control its behavior, you may execute any of the menu commands from another application. See the "Scripting and MacHTTP" section below or examine MacHTTP's AppleEvent dictionary (aete reource) for more details.

File Menu

This one is simple. All you can do is quit.

Edit Menu

This, too, is an easy to explain menu. It does nothing and is included because Apple's Human Interface guidelines suggest that an Edit menu be included in all applications.

Options Menu

This menu actually does something interesting. This menu contains commands that enable or disable certain MacHTTP functions.

Verbose Messages: Causes MacHTTP to produce much more status information about client requests and what the program is doing internally. You should enable this option if you are having trouble with MacHTTP and aren't sure what's going on. The cryptic nature of these messages is sure to help add to the confusion, since most pertain to internal MacTCP state information. However, some of the messages are useful for watching details of client requests, etc.

Suspend Logging: Temporarily closes MacHTTP's log file (if a log file is specified in the config file), allowing you to open and examine the log file with a text editor. All incoming connection information will not be logged to the file while this option is enabled.

Hide Window in Background: Works the same as the HIDEWINDOW command in the config file, described above.

Refuse New Connections: This option allows busy servers to remain running, but not allow any new clients to connect. All currently queued clients will be served, but no new connections will be accepted. Clients will be notified that connections are being refused. This option is useful for gracefully shutting down a server, or allowing you to change HTML documents while the server is running.

4.0 Serving Documents

HTML documents, including file references, links, anchors, and naming conventions used by MacHTTP are 100% compatible with those used by Unix-based HTTP servers. MacHTTP communicates with WWW clients running on any platform.

It is important to note that MacHTTP can interpret both Unix and Mac file specifications. Typically, HTML documents are written using Unix path names, etc. while file names specified within MacHTTP's config file use Mac file naming conventions.

MacHTTP also understands Macintosh aliases. If you create an alias to a document for MacHTTP to serve, MacHTTP will use the name of the alias for suffix mapping, then translate the alias to find the original file's contents.

File Locations

MacHTTP always expects that the files requested by WWW clients will reside in the same folder as MacHTTP, or subfolders within this folder. This means that clients cannot explicitly request files that live outside of the folder tree where MacHTTP resides. MacHTTP behaves this way for security reasons, since this prevents people for requesting files on your Mac besides those you explicitly place within the view of MacHTTP.

This means that the "root" of MacHTTP's file system starts with the folder it resides in. Clients requesting documents from MacHTTP specify URLs as if MacHTTP was at the root of the file system.

How MacHTTP interprets file names

MacHTTP goes through the following steps when interpreting a client's request for a specific file: